package com.koicarp.agent.rag;//package com.koicarp.langchain;
//
//import java.util.List;
//
//import org.dromara.milvus.plus.model.vo.MilvusResp;
//import org.dromara.milvus.plus.service.MilvusService;
//import org.springframework.util.StringUtils;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import com.koicarp.langchain.entity.Trouble;
//
//import cn.hutool.core.collection.ListUtil;
//import cn.hutool.core.io.file.FileReader;
//import cn.hutool.json.JSONUtil;
//import dev.langchain4j.data.embedding.Embedding;
//import dev.langchain4j.model.embedding.onnx.allminilml6v2.AllMiniLmL6V2EmbeddingModel;
//import dev.langchain4j.model.output.Response;
//import io.milvus.v2.service.vector.response.InsertResp;
//
//@RestController
//@RequestMapping("milvus")
//public class MilvusController {
//
//	private final TroubleMapper troubleMapper;
//	
//	private final MilvusService milvusService;
//	
//	public MilvusController(TroubleMapper troubleMapper,MilvusService milvusService) {
//		super();
//		this.troubleMapper = troubleMapper;
//		this.milvusService = milvusService;
//	}
//
//	@RequestMapping("add")
//	public  void add() {
//		//默认UTF-8编码，可以在构造中传入第二个参数做为编码
//		FileReader fileReader = new FileReader("C:\\Users\\dell.pc\\Desktop\\trouble5000.json");
//		String result = fileReader.readString();
//		List<Trouble> troubles = JSONUtil.toList(result, Trouble.class);
//		AllMiniLmL6V2EmbeddingModel embeddingModel = new AllMiniLmL6V2EmbeddingModel();
//		for (Trouble trouble : troubles) {
//			if (!StringUtils.hasLength(trouble.getLiableAdvice())) {
//				trouble.setLiableAdvice("");
//			}
//			if (trouble.getName().length() > 256) {
//				trouble.setName(trouble.getName().substring(0, 100));
//			}
//			trouble.setVector(embeddingModel.embed(trouble.getName()).content().vectorAsList());
//		}
////		
//		List<List<Trouble>> split = ListUtil.split(troubles, 200);
//		for (List<Trouble> temps : split) {
//			MilvusResp<InsertResp> resp = troubleMapper.insert(temps);
//			System.out.println();
//		}
//	}
//	
//	@RequestMapping("delete")
//	public void deleteCollection() {
//		milvusService.dropCollection("trouble_20250219");
//	}
//	
//}
